var gulp = require('gulp-help')(require('gulp'));
var requireDir = require('require-dir');
var minimist = require('minimist');
var sequence = require('gulp-sequence');
var run = require('gulp-run');
var del = require('del');

// 引入tasks的任务
var dir = requireDir('./tasks');

var knownOptions = {
    string: 'env',
    default: {env: process.env.NODE_ENV || 'prd', lang: 'zh_CN'}
};
var options = minimist(process.argv.slice(2), knownOptions);

// 启动watch任务
gulp.task('default', '默认任务，开启个模块的watch，sass编译、common模块js合并等', [
    'task-servicecenter',
    'task-shared',
    'task-index'
], function () {

});

// 构建dist工程(顺序执行，执行构建前先进行单元测试)
gulp.task('build', '编译任务，将所有模块构建为dist',
    sequence(
        'build-shared',
        'build-servicecenter',
        'build-index'
    ), {
        options: {
            'lang zh_CN': '构建中文环境的dist，不指定参数时默认',
            'lang en_US': '构建英文环境的dist'
        }
    }
);

gulp.task('build-all', '一键编译，同时构建中文和英文版本', function () {
    run('gulp build --lang zh_CN & gulp build --lang en_US').exec();
});